/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ctrl;

import java.io.IOException;
import java.nio.CharBuffer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrateur
 */
public class ThreadSimul extends Thread {

    private final WorldCtrl ctrl;
    private boolean isRunning = true;
    private int speed = 500;


    ThreadSimul(WorldCtrl ctrl, int speed) {
        this.ctrl = ctrl;
        this.speed = speed;
    }

    @Override
    public void run() {
        try {
        while (isRunning) {
            ctrl.doMove();
            
                Thread.sleep(speed);
            } 
        }
        catch (InterruptedException ex) {
                Logger.getLogger(ThreadSimul.class.getName()).log(Level.SEVERE, null, ex);
            }

    }
    public void stopRunning(){
        isRunning = false;
    }
}
